<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Widget</title>

    <!-- Styles -->
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/helper.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
</head>

<body class="bg-primary">

    <div class="unix-login">
        <div class="container-fluid">
            <div class="row justify-content-center">
                <div class="col-lg-6">
                    <div class="login-content">
                        <div class="login-form">
                            <h4>Administratior Register</h4>
                            <form>
                                <div class="form-group">
                                    <label>username</label>
                                    <input type="text" class="form-control" id="username" name="username" placeholder="username">
                                </div>
                                <div class="form-group">
                                    <label>Password</label>
                                    <input type="password" class="form-control" id="password" name="password" placeholder="password">
                                </div>
                                <div class="checkbox">
                                    <label class="pull-right">
										<a href="yl-login.html">登录</a>
									</label>
                                </div>
                                <script type="text/javascript" src="jquery-1.8.3.min.js"></script>
                                <button type="button" onclick="register()" class="btn btn-primary btn-flat m-b-30 m-t-30">注册</button>
                                <script>
                                    function register() {
                                        var username = $("#username").val();
                                        var password = $("#password").val();
                                        if(username == '' || password == ''){
                                            alert('请将信息输入完整')
                                            return;
                                        }
                                        $.ajax({
                                            url: "/user/register",
                                            type: "post",
                                            async: false,
                                            cache: false,
                                            data: {"username": username,
                                                "password": password},
                                            dataType: "text",
                                            "success":function(json) {
                                                alert(json);
                                                if("注册成功"!=json){
                                                    $("#username").val("");
                                                    $("#password").val("");
                                                }else {
                                                    window.location.href="yl-login.html";
                                                }
                                            }
                                        });

                                    }
                                </script>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>

</html>
